
//Funcoes Uteis
#include <string.h>
#include <stdio.h>
#ifndef UTIL_H
#define UTIL_H

int getStringTam(char* str)
{
    int size =0;
    int i =0;
    for(i=0;str[i]!='\0';i++)
        size++;

    return size;
}


void CopiaString(char* origem, char* destino)
{

    int i;
    for(i=0;origem[i]!='\0';i++)
      destino[i] = origem[i];

    destino[i]='\0';

}

FILE* abrirArquivoLeitura(char* _strFileName)
{
    return fopen( _strFileName, "r" );
}

int lerLinha(FILE* _file ,char* _strLine, int tamLinha)
{
    if( fgets ( _strLine, tamLinha, _file ) != NULL ) /* read a line */
        fputs ( _strLine, stdout ); /* write the line */
    else
        return 0;

    return 1;
}

void fecharArquivo(FILE* _pFile)
{
    if(_pFile != NULL)
        fclose(_pFile);
}

int ComparaString(char* str1,char*str2)
{
    int i=0;
    int j=0;

    while( (str1[i]!='\0') && (str2[j]!='\0'))
    {
        if(str1[i] > str2[j])
          return 1;
         if(str1[i] < str2[j])
          return -1;

          i++;
          j++;
    }

    return 0;
}
#endif
